<?php
/**
 * @todo still need to be implemented
 */
Class Xgmml{
	// site:gephi.org
	function site_to_xgmml(){
		$pdo = new DB_Pdo('vandersanden'); // new pdo object
		$result = $pdo->prepare('select id,url,links,name,parsed from crawler');
		$result->execute();
		$pagesarray = $result->fetchAll(PDO::FETCH_ASSOC);
		$xml = "<?xml version=\"1.0\"?>\n
				<graph directed=\"1\" id=\"0\" label=\"Site Root\">\n";

		foreach ($pagesarray as $page){
			$xml .= "<node id=\"".$page['id']."\" label=\"".$page['name']."\">";
			$xml .= "<att name=\"url\" value=\"".$page['url']."\"/>";
			$xml .=	"<att name=\"exists\" value=\"".$page['parsed']."\"/>";
			$xml .= "</node>\n";
			$xml .= "<edge source=\"".$page['id']."\" target=\"".$page['links']."\" label=\"Edge from node ".$page['id']." to node ".$page['links']."\"></edge>\n";
		}
		$xml .= "</graph>";
		echo $xml;
		$pdo = null;
		$result = null;
	}
}
?>